﻿using UnityEngine;

public class ResourcePath  {

    private static readonly string bundleConfigPath = "BundleConfig/BundleConfig";
    private static readonly string unitTestFolder = "HeartBeatUnitTest";
    private static readonly string hotFixFolderName = "HotFix";
    private static readonly string guiDependencyPath = "GUIDependency/GUIDependency";

    public static string HotFixFolderName
    {
        get
        {
            return hotFixFolderName;
        }
    }

    public static string BundlePath
    {
        get
        {
            string baseBundlePath = string.Empty;
#if UNITY_EDITOR
            bool useResources = true;

            useResources = PlayerPrefs.GetString("ResourceLoadTypeKey") == "Resources";
            if (useResources)
            {

            }
            else
            {
                 baseBundlePath = Application.dataPath + "/../../" + unitTestFolder + "/Bundle";
            }
#else
            baseBundlePath = Application.persistentDataPath + "/" + HotFixFolderName +"/Bundle";
#endif
            return baseBundlePath;
        }
    }

    // USED in UnitTest status and iOS, Android
    public static string BundleFilePath
    {
        get
        {
            return BundlePath + "/Bundle";
        }
    }

    //Lua文件夹的路径，在三个环境中都需要有值
    public static string LuaFolderPath
    {
        get
        {
            string luaPath = string.Empty;
#if UNITY_EDITOR
            bool useResources = true;

            useResources = PlayerPrefs.GetString("ResourceLoadTypeKey") == "Resources";
            if (useResources)
            {
                luaPath = Application.dataPath + "/Lua";
            }
            else
            {
                luaPath = Application.dataPath + "/../../" + unitTestFolder + "/Lua";
            }
#else
            luaPath = Application.persistentDataPath + "/" + HotFixFolderName + "/Lua";
#endif
            return luaPath;
        }
    }

    public static string BasePath
    {
        get
        {
            string basePath = string.Empty;
#if UNITY_EDITOR
            bool useResources = true;

            useResources = PlayerPrefs.GetString("ResourceLoadTypeKey") == "Resources";
            if (useResources)
            {

            }
            else
            {
                basePath = Application.dataPath + "/../../" + unitTestFolder;
            }
#else
            basePath = Application.persistentDataPath + "/" + HotFixFolderName;
#endif
            return basePath;
        }

    }

    // USED in UnitTest status
    public static string UnitBasePath
    {
        get
        {
            return Application.dataPath + "/../../" + unitTestFolder;
        }
    }

    public static string BundleConfigPath
    {
        get
        {
            string configPath = string.Empty;
#if UNITY_EDITOR
            bool useResources = true;

            useResources = PlayerPrefs.GetString("ResourceLoadTypeKey") == "Resources";
            if (useResources)
            {
                configPath = Application.dataPath + "/Resources/" + HotFixFolderName + "/" + bundleConfigPath + ".txt";
            }
            else
            {
                configPath = Application.dataPath + "/../../" + unitTestFolder + "/" + bundleConfigPath + ".txt";
            }
#else
            configPath = Application.persistentDataPath + "/" + HotFixFolderName + "/" + bundleConfigPath + ".txt";
#endif
            return configPath;
        }

    }

    public static string GUIDependencyPath
    {
        get
        {
            string path = string.Empty;
#if UNITY_EDITOR
            bool useResources = true;

            useResources = PlayerPrefs.GetString("ResourceLoadTypeKey") == "Resources";
            if (useResources)
            {
                path = Application.dataPath + "/Resources/" + HotFixFolderName + "/" + guiDependencyPath + ".txt";
            }
            else
            {
                path = Application.dataPath + "/../../" + unitTestFolder + "/" + guiDependencyPath + ".txt";
            }
#else
            path = Application.persistentDataPath + "/" + HotFixFolderName + "/" + guiDependencyPath + ".txt";
#endif
            return path;
        }
    }
}
